﻿
Public Structure autolock(Of l As {locks.ilock, Structure})
    Implements IDisposable

    Private i As Object

    Public Sub New(ByRef i As lock(Of l))
        Me.i = i
        i.wait()
    End Sub

    Public Sub Dispose() Implements IDisposable.Dispose
        CType(Me.i, lock(Of l)).release()
    End Sub
End Structure
